{% load static %}
<!DOCTYPE HTML>
<html lang="zh-CN">
	<head>
		<title>系统登录</title>
		<link href="{% static 'plugins/login/css/style.css' %}" rel="stylesheet" type="text/css" media="all"/>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<!-- -->
		
		<script src="{% static 'plugins/login/js/jquery.min.js' %}"></script>
	</head>
	<body>
		<!-- contact-form -->
		<div class="message warning">
			<div class="inset">
				<div class="login-head">
					<h1>用户登录</h1>
				</div>
				<form id="loginform">
					{% csrf_token %}
					<li>
						<input type="text" class="text" placeholder="用户名" name="username">
						<a href="#" class=" icon user"></a>
					</li>
					<div class="clear"></div>
					<li>
						<input type="password" placeholder="密码" name="password">
						<a href="#" class="icon lock"></a>
					</li>

					<p id="error_text"></p>

					<div class="clear"></div>
					<div class="submit">
						<div class="submit">
							<input type="button" value="登   录" id="login_btn">
							<!--<h4><a href="#">Lost your Password ?</a></h4>-->
							<div class="clear"></div>
						</div>
					</div>
				
				</form>
			</div>
		</div>
		<div class="clear"></div>
		<!--- footer --->
		<div class="footer">
			<p>Copyright &copy; 2022.</p>
		</div>
		<script>
            $(function () {
                UserLogin();
            })

            function UserLogin() {
                $('#login_btn').click(function () {
                    $.ajax(
                        {
                            url: '/ajax_login/',
                            type: 'post',
                            data: $('#loginform').serialize(),
                            success: function (data) {

                                if (data.status == 1000) {
                                    window.location.href = '/index/';
                                } else {
                                    alert(data.msg);
                                }
                            }
                        }
                    )
                })
            }
		</script>
	</body>
</html>